<%@ page contentType="text/html; charset=utf-8" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>借阅审核</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <jsp:include page="/inc/head.jsp" flush="true"/>
    <link href="${basePath}/js/activiti/qtip/jquery.qtip.min.css" type="text/css" rel="stylesheet" />
    <link href="${basePath}/js/activiti/jquery-ui-1.9.2.custom.css" type="text/css" rel="stylesheet" />
    <link href="${basePath}/js/activiti/style-ui.css" type="text/css" rel="stylesheet" />
    <jsp:include page="/inc/footer.jsp" flush="true"/>
    <script src="${basePath }/js/tip.js"></script>
    <!-- picker -->
    <script src="${basePath}/js/My97DatePicker/WdatePicker.js"></script>
    <script src="${basePath}/js/activiti/qtip/jquery.qtip.pack.js" type="text/javascript"></script>
    <script src="${basePath}/js/activiti/jquery.outerhtml.js" type="text/javascript"></script>
    <script src="${basePath}/js/activiti/jquery-ui-1.9.2.min.js" type="text/javascript"></script>
    <script src="${basePath }/js/module/activiti/workflow.js"></script>
    <script src="${basePath }/serverJs/borrowAudit.js"></script>
        <style type="text/css">
        /****************** 审核的样式 *************/

        #borAuditInfo table{
            font-size: 14px;
        }
        #borAuditInfo td{
            padding-left: 20px;
            height: 30px;
            /*width: 50%;*/
        }
        .firstTD{
            color: #9d9d9d;
        }
        #borAuditInfo tr{
            margin-top: 60px;
        }
        #auditUserView{
            border: 1px solid #AAAAAA;
            border-radius: 3px;
            height: 60px;
            /*width: 250px;*/
        }
        /****************** 审核的样式 *************/
        .content{
            padding-left: 20px;
        }
        .bigLongText{
            width:95%;
            height:200px;
        }
        .textAreaLength{
            width:100%;
            height:100px;
        }
        #borrowDeptTable tr,#borrowNoDeptTable tr{
            /*width: 100%*/
        }
        #borrowDeptTable select, #borrowNoDeptTable select{
            /*width:140px;*/
        }
        #borrowNoDeptTable input , .textAreaLength,#borrowDeptTable input,#modifyApply input{
            border: 1px solid #AAAAAA;
            border-radius: 3px;
            width:100%;
            /*height:28px;*/
        }
        .rejectReason{
            height: 40px;
            /*width:85%;*/
            background: yellow;
            margin-left: 20px;
            border: 1px solid cornflowerblue;
            border-radius: 3px;
        }
        td{
            /*font-size: 13px;*/
            /*height:40px;*/
        }
        .content .box {
            border-top:0;
        }
        .content .bootstrap-table .fixed-table-toolbar .icon-refresh {
            padding: 3px 0;
        }
        .content .bootstrap-table .fixed-table-toolbar .bs-bars, .fixed-table-toolbar .columns {
            margin-top: 0;
        }
        .content #rowTable .box .bootstrap-table .fixed-table-toolbar {
            position: absolute;
            right: 0;
            top: -34px;
        }
        .content #rowTable .box .bootstrap-table .fixed-table-container {
            margin-top: 10px;
        }
          #modifyApply  form label {
              font-weight: 400;
            }
        .pagination>.active>a {
            background-color:#337ab7!important;
            color:#fff!important;
        }
    </style>
</head>
<body class="hold-transition skin-blue sidebar-mini" style="overflow:hidden;">
<!-- Main content -->
<section class="content">
    <div id="listBar" class="btn-group">
        <shiro:hasPermission name="cms:borAudit:myAudit">
        <button id="btn_myAudit" type="button" class="btn btn-default" onclick="myAuditAction()">
            <span class="glyphicon glyphicon-paste" aria-hidden="true"></span> 待办审批
        </button>
        </shiro:hasPermission>
        <shiro:hasPermission name="cms:borAudit:myRun">
        <button id="btn_myRun" type="button" class="btn btn-default" onclick="myRunAction()">
            <span class="glyphicon glyphicon-paste" aria-hidden="true"></span> 运行中的审批
        </button>
        </shiro:hasPermission>
        <shiro:hasPermission name="cms:borAudit:myHistory">
        <button id="btn_myHistory" type="button" class="btn btn-default" onclick="myHistoryAction()">
            <span class="glyphicon glyphicon-paste" aria-hidden="true"></span> 历史审批
        </button>
        </shiro:hasPermission>
    </div>
    <div id = "rowTable" class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-body table-responsive no-padding" id="borAuditDiv">
                    <!-- 当前的代办table -->
                    <table id="borAuditTable">
                    </table>
                </div>

                <div  id="myRunDiv" style="display: none">
                    <!-- 当前我的运行的table -->
                    <table id="myRunTable">
                    </table>
                </div>

                <div  id="myHistoryDiv" style="display: none">
                    <!-- 当前的历史table -->
                    <table id="myHistoryTable">
                    </table>
                </div>
            </div>
        </div>
    </div>

    <!-- 借阅申请的内容 -->
    <div id="borAuditInfo" class="modal fade archivePopUp" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content" <%--style="width:580px;"--%> >
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">
                        <i class="icon-pencil"></i>
                        <span id="filesTitle" style="font-weight:bold"> </span>
                    </h4>
                </div>
                <div class="modal-body">
                <table>
                    <tr>
                        <td style="width:120px">申请时间：</td>
                        <td id="createTime" class="firstTD"></td>
                    </tr>
                    <tr>
                        <td >借&nbsp;&nbsp;阅&nbsp;&nbsp;人：</td>
                        <td id="borUserName" class="firstTD"> </td>
                    </tr>
                    <tr>
                        <td>所属部门：</td>
                        <td id="borDeptName" class="firstTD"></td>
                    </tr>
                    <tr>
                        <td >借阅类型：</td>
                        <td id="borTaskType" class="firstTD"></td>
                    </tr>

                    <tr>
                        <td >借阅方式：</td>
                        <td id="borrowType" class="firstTD"> </td>
                    </tr>

                    <tr id="borAttestUrlTr">
                        <td>借阅凭证：</td>
                        <td >
                            <input type="hidden" class="firstTD" id="urlHidden" value="" />
                            <input type="button" id="borAttestUrl" value="查看凭证" />
                        </td>
                    </tr>
                    <%--<tr>
                        <td>借&nbsp;&nbsp;&nbsp;阅&nbsp;&nbsp;档&nbsp;&nbsp;案：</td>
                        <td id="borFileName" class="firstTD"></td>
                    </tr>--%>
                    <%--<tr>
                        <td>借&nbsp;&nbsp;&nbsp;阅&nbsp;&nbsp;时&nbsp;&nbsp;间：</td>
                        <td id="borTime" class="firstTD"></td>
                    </tr>--%>
                    <tr>
                        <td>预计归还时间：</td>
                        <td id="planReturnTime" class="firstTD"></td>
                    </tr>
                    <tr>
                        <td>借阅事由：</td>
                        <td id="borPurpose" class="firstTD"></td>
                    </tr>
                    <tr>
                        <td>审批意见：</td>
                        <td>
                            <textarea class="bigLongText" id="auditUserView" name="auditUserView" maxlength="20">
                            </textarea>
                        </td>
                    </tr>
                    <%--<tr>
                        <td colspan="2">
                            <textarea class="bigLongText" id="auditUserView" name="auditUserView" maxlength="20">
                            </textarea>
                        </td>
                    </tr>--%>
                    <tr id="auditPointUserDiv" style="display: none" >
                        <td  class="content">指定下级领导审批：</td>
                        <td class="form-group">
                            <select id="auditUserTable" data-delegateUser="" style="width: 80%">
                            </select>
                        </td>
                    </tr>
                </table>
                </div>
                <div class="modal-footer ">
                    <input type="hidden" id="borId" value="">
                    <input type="hidden" id="taskId" value="">
                    <input type="hidden" id="taskType" value="">
                    <button type="button" class="btn btn-success" id="passSumbit" onclick="borAuditResult(1);">通过</button>
                    <button type="button" class="btn btn-danger" id="rejectSumbit" onclick="borAuditResult(0);">驳回</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </div>

    <%--重新申请的流程--%>
    <div id="modifyApply" class="modal fade bs-example-modal-lg addUpdateInfo" role="dialog"
         aria-labelledby="myLargeModalLabel">
        <div class="modal-dialog " role="document">
            <div class="modal-content" style="width: 600px;">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                            aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title" id="againAuditLabel">流程办理[调整申请]</h4>
                </div>
                <div class="modal-body" style="height: 400px;">

                    <form class="form" role="form" style="padding-left:10px;">
                        <div class="form-group">
                            <label>领 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;导：</label>
                            <span id="rejectReason" ></span>
                        </div>
                       <div class="form-group">
                           <label class="control-label">申请类别：</label>
                           <label class="radio-inline">
                               <input type="radio" class="radio" name="adStatus" id="adStatus_1" value="1" style="width:auto;"> 调整申请
                           </label>
                           <label class="radio-inline">
                               <input type="radio" class="radio"  name="adStatus" id="adStatus_0" value="0" style="width:auto;" checked> 取消申请
                           </label>
                       </div>


                        <!-- 具有证明的申请 借阅重新申请 -->
                        <div style="display: none;" id="borrowNoDeptTable">
                            <div class="form-group">
                                <label for="borDept" class="control-label">借阅部门：</label>
                                <input class="form-control" type='text' id="borDept" name="borDept" value='' style="width:80%;display: inline-block;"/>
                            </div>

                            <div class="form-group">
                                <label for="borDept" class="control-label">借阅凭证：</label>
                                <input class="form-control" type='file' id="borrowNoDeptfile" name="file" value='' style="width:80%;display: inline-block;"/>
                            </div>
                            <div class="form-group">
                                <label for="borDept" class="control-label">借阅形式：</label>
                                <select class="form-control"  id="borType" name="borType" disabled style="width:80%;display: inline-block;">
                                    <option value="0">线上</option>
                                    <option value="1">线下</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <label for="borDept" class="control-label">归还时间：</label>
                                <input type='planReturnTime' id="returnNoDeptTime" name="returnTime" onClick='WdatePicker()' style="width:80%;display: inline-block;"/>
                            </div>
                            <div class="form-group">
                                <label for="borDept" class="control-label" style="vertical-align: top;">借阅原因：</label>
                                <textarea class="textAreaLength" id="borNoDeptPurpose" name="borPurPose" maxlength="20" style="width:80%;display: inline-block;"/>
                                    </textarea>
                            </div>
                        </div>


                        <!-- 具有组织部门的申请列表 -->
                        <div style="display: none;" id="borrowDeptTable">
                            <div class="form-group">
                                <label for="borDeptTwo" class="control-label">借阅部门：</label>
                                <input class="form-control" type='text' id="borDeptTwo" name="borDept" value='' style="width:80%;display: inline-block;"/>
                            </div>

                            <div class="form-group">
                                <label for="borDept" class="control-label">归还时间：</label>
                                <input type='text' id="planReturnTimeTwo" name="planReturnTimeTwo" onClick='WdatePicker()' style="width:80%;display: inline-block;"/>
                            </div>
                            <div class="form-group">
                                <label for="borDept" class="control-label">借阅形式：</label>
                                <select class="form-control"  id="borTypeTwo" name="borType" disabled style="width:80%;display: inline-block;">
                                    <option value="0">线上</option>
                                    <option value="1">线下</option>
                                </select>
                            </div>

                            <div class="form-group">
                                <label for="borDept" class="control-label" style="vertical-align: top;">借阅原因：</label>
                                <textarea class="textAreaLength" id="borPurposeTwo" name="borPurPose" maxlength="20" style="width:80%;display: inline-block;"/>
                                </textarea>
                            </div>
                        </div>

                        <!--  续借重新申请  -->
                        <div style="display: none;" id="renewTable">
                            <div class="form-group">
                                <label for="borDept" class="control-label">续借时间：</label>
                                <input class="form-control" type='text' id="renewTime" name="returnTime" onClick='WdatePicker()' style="width:80%;display: inline-block;"/>
                            </div>

                            <div class="form-group">
                                <label for="borDept" class="control-label">续借原因：</label>
                                <textarea class="textAreaLength" id="renewPurpose" name="renewPurpose" maxlength="20" style="width:80%;display: inline-block;"/>
                                </textarea>
                            </div>
                            <div class="form-group" id="modifyPointUserDiv" style="display: none">
                                <label for="borDept" class="control-label">指定下级领导审批：</label>
                                <select class="form-control"  id="modifyUserTable"  data-delegateUser=""   style="width:70%;display: inline-block;">

                                </select>
                            </div>

                        </div>
                    </form>
                </div>
                <div class="modal-footer ">
                    <input type="hidden" id="borModifyId" value="">
                    <input type="hidden" id="taskModifyId" value="">
                    <input type="hidden" id="applyTableType" value="">
                    <input type="hidden" id="modifyTaskType" value="">
                    <button type="button" class="btn green" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" id="createDefine" onclick="borAuditOption.borAuditFinishResult(this);">确认</button>
                </div>
            </div>
        </div>
    </div>

    <!--------------------------归档卷内件列表---------------------------->
    <div id="viewArchiveModel" class="modal fade addUpdateInfo" tabindex="-1" role="dialog"  aria-labelledby="myModalLabel" aria-hidden="true" style="/*width:1800px;*/text-align: center;" >
        <div class="modal-dialog" style="width:1000px;">
            <div class="modal-content" style="height: 530px">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">浏览的列表</h4>
                </div>
                <div class="modal-body">
                <table id="viewArchiveTable" class="RollItemTable">
                </table>
                <input id="volumeIdRefreshArchive" name="volumeIdRefresh" type="hidden">
                </div>
            </div>
        </div>
    </div>

    <!-- 查看文件证明 -->
    <div id="showImg" class="modal fade archivePopUp" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog" style="width:900px;height: 700px;text-align: center;">
            <div class="modal-content" style="height: 100%;">
                <div id="borAttestPdf" style="height:100%;width: 100%">
                    <img id="borAttestImg" style="height:100%;width: 100%;display: none" />
                </div>
            </div>
        </div>
    </div>
</section>

<script type="text/javascript">

    //当前代办table
    var $borAuditTable = $("#borAuditTable");
    //我的正在运行的流程
    var $myRunTable = $("#myRunTable");
    //我的历史申请流程
    var $myHistoryTable = $("#myHistoryTable");

    //档案类型json
    var fileTypeJson = {};

    //自动加载
    $(function(){
        showBorAuditTable();

        //根据单选结果获取改变时间内容
        $('#modifyApply').find(":radio").change(function() {
            var isRepply = $(this).val();
            //获取当前要显示的申请table
            var applyTableType = $("#applyTableType").val();
            if(isRepply==0){
                $("#"+applyTableType).hide();
            }else{
                $("#"+applyTableType).show();
            }
        })


        findAllJudType();

        //查看文件证明图片
        $("#borAttestUrl").click(function(){
            var imgUrl = $("#urlHidden").val();
            if(imgUrl.indexOf("pdf")!=-1){
                $("#borAttestImg").hide();
                var options={
                    pdfOpenParams: {
                        pagemode: "thumbs",
                        navpanes: '0',
                        /*toolbar: '0',*/ //去掉工具栏,打印,下载等,,,,
                        statusbar: '0',
                        view: 'FitV'
                    }};
                //var url="${basePath} /localpdf/大型网站技术架构_核心原理与案例分析_李智慧.pdf";
                var myPDF = PDFObject.embed(imgUrl, "#borAttestPdf", options);
            }else{
                $("#borAttestImg").show();
                $("#borAttestImg").attr({ src: imgUrl, alt: "查看图片" });
            }
            $("#showImg").modal("show");
        })
    })

    //所有的档案类型
    function findAllJudType(){
        $.ajax({
            type: "POST",
            url:"${pageContext.request.contextPath }/pcwindow/findAllJudType",
            dataType:"json",
            async:false,
            success: function(data){
                if (data.length != 0) {
                    var arcTypes = data.rows;
                    for(var i = 0;i < arcTypes.length ;i++){
                        var tyname=arcTypes[i].sortName;
                        var tyid=arcTypes[i].sortNum;
                        fileTypeJson[tyid] = tyname;
                    }
                }
            }
        });
    }

    /************************************当前代办的流程总览（开始）****************************/
    //显示待办流程
    function myAuditAction(){
        $("#borAuditDiv").show();
        $("#myHistoryDiv").hide();
        $("#myRunDiv").hide();
        $borAuditTable.bootstrapTable("destroy");
        showBorAuditTable();
    }

    function showBorAuditTable(){
        $borAuditTable.bootstrapTable({
            url: "${basePath}/pcwindow/getMyAudit",
            queryParams: "defaultParams",
            striped: true,
            search: false,
            showRefresh: true,
            showColumns: true,
            minimumCountColumns: 2,
            clickToSelect: true,
            detailView: false,
            detailFormatter: 'detailFormatter',
            pagination: true,
            pageSize: 50,
            pageList:[50,100],
            paginationLoop: false,
            sidePagination: 'server',
            silentSort: false,
            smartDisplay: false,
            escape: true,
            searchOnEnterKey: true,
            idField: 'id',
            maintainSelected: true,
            toolbar: '#toolbar',
            columns:[
                {field: 'id', visible:false},//借阅登记表的id
                {field: 'taskId', visible:false},//当前工作流的流程id
                {field: 'registerNum', title: '登记号', align: 'center'},
                {field: 'taskType', title: '申请类型', align: 'center',formatter:'taskTypeFormat'},
                {field: 'borFileName', title: '借阅文件', align: 'center'},
//                {field: 'volCaseNum', title: '档案档号', align: 'center',formatter:'extend1Format'},
                {field: 'borUserName', title: '借阅人', align: 'center'},
                {field: 'createTime', title: '申请时间', align: 'center',formatter:'timeFormat'},
//                {field: 'borTime', title: '借阅时间', align: 'center',formatter:'LongToDateFormat'},
                {field: 'planReturnTime', title: '截止归还时间', align: 'center',formatter:'planReturnFormat'},
//                {field: 'taskName', title: '当前节点', align: 'center',formatter:'taskNameFormat'},
//                {field: 'status', title: '流程状态', align: 'center',formatter:'statusFormat'},
                {field: 'action', title: '操作', align: 'center',formatter:'actionFormat'}
            ],
            onLoadSuccess:function(data){
                //无数据隐藏分页
                if(data && data.total == 0){
                    $('.fixed-table-pagination').hide()
                }
            }
        })
        $borAuditTable.bootstrapTable('resetView',{height:setHeight()});

    }

    /**
     * 表格高度自适应
     * @return
     * winTop 浏览器视口高度
     * header 顶部通栏
     * breadcrumb 面包屑
     * mainFooter 底部
     */
    function setHeight(){
        var winTop = $(window.top).height(),
            header = window.top.document.querySelector('.main-header').offsetHeight,
            breadcrumb =  window.top.document.querySelector('.breadcrumb').offsetHeight,
            mainFooter = window.top.document.querySelector('.main-footer').offsetHeight;
        return winTop-header-breadcrumb-mainFooter-10;
    }

    function actionFormat(value,row,index){
        return [
            '<shiro:hasPermission name="cms:borAudit:myAudit"><a class="update" href="javascript:;" onclick="auditAction(' + row.id +','+row.taskId+','+index+')"  data-toggle="tooltip" title="audit">回复</a></shiro:hasPermission>&nbsp;&nbsp;&nbsp;',
            '<shiro:hasPermission name="cms:borAudit:myAudit"><a class="update" href="javascript:;" onclick="infoAction('+index+')"  data-toggle="tooltip" title="audit">详情</a></shiro:hasPermission>'
        ].join('');
    }

    //弹出审核内容
    function auditAction(borId,taskId,index){
        $("#auditUserView").val("");
        var data =  $borAuditTable.bootstrapTable('getData')[index];
        //当前节点的英文名称
        var tkey = data.taskDefinitionKey;
        //当前节点的中文名称
        var taskName = data.taskName;
        if(tkey.indexOf("modifyApply")!=-1){
            tkey = "modifyApply";
        }
        var func = borAuditOption[tkey];
        //是否为指定审核人
        var pointUserStatus = false;
        //指定的用户代词为什么
        var pointUser = '';
        $.ajax({
            url:"${basePath}/activiti/common/selectNextTaskUser/"+data.taskId,
            type:"get",
            async:false,
            dataType:"json",
            success:function (data) {
                var code = data.code;
                //当前为指定人选
                if(code==1){
                    pointUserStatus = true;
                    // 当前流程中 赋予的代表用户${user }===> user
                    pointUser = data.message;
                }else{
                    if(data.message!=null){
                        Ewin.alert(data.message);
                        return;
                    }
                }
            }
        })
        if(func!=null||typeof(func)!="undefined"){
            func(borId,taskId,data,pointUserStatus,pointUser);
        }else{
            borAuditOption.processHandle(borId,taskId,data,taskName,pointUserStatus,pointUser);
        }
    }



    //查看详情
    function infoAction(index){
        var data =  $borAuditTable.bootstrapTable('getData')[index];
        var borId = data.id;
        $('#viewArchiveModel').modal({
            keyboard: true
        });
        var opt = {
            url: '${basePath}/pcwindow/getBorrowInfoByBorId?borId=' + borId,
            silent: true,
        };
        $("#viewArchiveTable").bootstrapTable('refresh', opt);
    }

    //借阅的列表
    $("#viewArchiveTable").bootstrapTable({
        height: 440,
        striped: true,//是否显示行间隔色
        // search: false,//是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
        showRefresh: false,//是否显示刷新按钮
        //showColumns: true,//是否显示所有的列
        minimumCountColumns: 2,//最少允许的列数
        clickToSelect: true,//是否启用点击选中行
        detailView: false,//是否显示父子表
        detailFormatter: 'detailFormatter',
        pagination: false,//是否显示分页（*）
        paginationLoop: false,
        sidePagination: 'server',//分页方式：client客户端分页，server服务端分页（*）
        silentSort: false,
        smartDisplay: false,
        escape: true,
        searchOnEnterKey: true,
        idField: 'itemId',
        maintainSelected: true,
        columns: [
            {field: 'ck', checkbox: true},
            {field: 'BORFILENAME', title: '题名', align: 'center'},
            {field: 'ITEMNAME', title: '文号', align: 'center'},
            {field: 'ITEMPAGE', title: '页次', align: 'center'},
            {field: 'ITEMTEMPORARY', title: '单元号', align: 'center'},
            {field: 'ITEMCREATETIME', title: '发文日期', align: 'center'},
            {field: 'ITEMRESPONS', title: '责任者', align: 'center'},
            {field: 'ITEMSECRET', title: '密级', align: 'center'},
            {field: 'ITEMSTATUS', title: '档案状态', formatter: 'statusFormatter'},
        ]
    });

    /**
     *	状态显示按钮
     */
    function statusFormatter(value, row, index) {
        if (value == 0) {
            return  '<font style="color:dodgerblue;">正常</font>'
        }
        if (value == 1) {
            return  '<font style="color:grey;">鉴定中</font>'
        }
        if (value == 2) {
            return  '<font style="color:grey;">借阅中</font>'
        }
    }
    /************************************当前代办的流程总览（结束）****************************/

    /************************************我的运行中的流程总览（开始）****************************/
    //查看运行中的流程
    function myRunAction(){
        $("#borAuditDiv").hide();
        $("#myHistoryDiv").hide();
        $("#myRunDiv").show();
        $myRunTable.bootstrapTable("destroy");
        showMyRun();
    }

    function showMyRun(){
        $myRunTable.bootstrapTable({
            url: "${basePath}/pcwindow/findRunningProcessInstaces",
            queryParams: "defaultParams",//此参数识别当前查询的正在运行的流程为何种流程borrowActiviti：借阅流程
            striped: true,
            search: false,
            showRefresh: true,
            showColumns: true,
            minimumCountColumns: 2,
            clickToSelect: true,
            detailView: false,
            detailFormatter: 'detailFormatter',
            pagination: true,
            pageSize: 50,
            pageList:[50,100],
            paginationLoop: false,
            sidePagination: 'server',
            silentSort: false,
            smartDisplay: false,
            escape: true,
            searchOnEnterKey: true,
            idField: 'id',
            maintainSelected: true,
            toolbar: '#toolbar',
            columns:[
                {field: 'id', visible:false},//借阅登记表的id
                {field: 'taskId', visible:false},//当前工作流的流程id
                {field: 'registerNum', title: '登记号', sortable: true, align: 'center'},
                {field: 'taskType', title: '申请类型', align: 'center',formatter:'taskTypeFormat'},
                {field: 'borFileName', title: '借阅文件', align: 'center'},
//                {field: 'volCaseNum', title: '档案档号', align: 'center',formatter:'extend1Format'},
                {field: 'fileType', title: '档案类型', align: 'center',formatter:'fileTypeFormat'},
                {field: 'borType', title: '借阅形式', align: 'center',formatter:'borTypeFormat'},
                {field: 'createTime', title: '申请时间', align: 'center',formatter:'timeFormat'},
//                {field: 'borTime', title: '借阅时间', align: 'center',formatter:'LongToDateFormat'},
                {field: 'planReturnTime', title: '截止归还时间', align: 'center',formatter:'planReturnFormat'},
//                {field: 'taskName', title: '当前节点', align: 'center',formatter:'taskNameFormat'},
//                {field: 'status', title: '流程状态', align: 'center',formatter:'statusFormat'},
                {field: 'taskAssignee', title: '当前处理人', align: 'center'}
            ],
            onLoadSuccess:function(data){
                //无数据隐藏分页
                if(data && data.total == 0){
                    $('.fixed-table-pagination').hide()
                }
            }
        })
    }

    /************************************我的运行中的流程总览（结束）****************************/

    /************************************我的历史的流程总览（开始）****************************/
    function myHistoryAction(){
        $("#borAuditDiv").hide();
        $("#myRunDiv").hide();
        $("#myHistoryDiv").show();
        $myHistoryTable.bootstrapTable("destroy");
        showMyHistoryTable();
    }

    function showMyHistoryTable(){
        $myHistoryTable.bootstrapTable({
            url: "${basePath}/pcwindow/findFinishedProcessInstaces",
            queryParams: "defaultParams",//此参数识别当前查询的正在运行的流程为何种流程borrowActiviti：借阅流程
            striped: true,
            search: false,
            showRefresh: true,
            showColumns: true,
            minimumCountColumns: 2,
            clickToSelect: true,
            detailView: false,
            detailFormatter: 'detailFormatter',
            pagination: true,
            pageSize: 50,
            pageList:[50,100],
            paginationLoop: false,
            sidePagination: 'server',
            silentSort: false,
            smartDisplay: false,
            escape: true,
            searchOnEnterKey: true,
            idField: 'id',
            maintainSelected: true,
            toolbar: '#toolbar',
            columns:[
                {field: 'id', visible:false},//借阅登记表的id
                {field: 'taskId', visible:false},//当前工作流的流程id
                {field: 'registerNum', title: '登记号', sortable: true, align: 'center'},
                {field: 'fileType', title: '档案类型', align: 'center',formatter:'fileTypeFormat'},
                {field: 'borUserName', title: '借阅人', align: 'center'},
                {field: 'borFileName', title: '借阅文件', align: 'center' },
//                {field: 'volCaseNum', title: '档案档号', align: 'center',formatter:'extend1Format'},
                {field: 'borType', title: '借阅形式', align: 'center',formatter:'borTypeFormat'},
//                {field: 'createTime', title: '申请时间', align: 'center',formatter:'timeFormat'},
//                {field: 'borTime', title: '借阅时间', align: 'center',formatter:'LongToDateFormat'},
                {field: 'planReturnTime', title: '截止归还时间', align: 'center',formatter:'finishPlanReturnFormat'},
                {field: 'taskCreateTime', title: '审批申请时间', align: 'center',formatter:'timeFormat'},
                {field: 'taskFinishTime', title: '审批结束时间', align: 'center',formatter:'timeFormat'},
                {field: 'extend2', title: '审批结果', align: 'center',formatter:'extend2Format'},
//                {field: 'borPurpose', title: '流程结束原因', align: 'center',formatter:'borPurposeFormat'},
//                {field: 'version', title: '流程版本', align: 'center',formatter:'versionFormat'},
            ],
            onLoadSuccess:function(data){
                //无数据隐藏分页
                if(data && data.total == 0){
                    $('.fixed-table-pagination').hide()
                }
            }
        })
    }


    //初始化页面参数
    function defaultParams(params) {
        return { activitiType: "borrowActiviti",limit: params.limit,offset: params.offset}
    }

    //初始化value为时间的转换
    function timeFormat(value,row,index){
        return formatDateTime(value);
    }

    //初始化value为时间的转换
    function LongToDateFormat(value,row,index){
        return formatshortDateTime(value);
    }

    //流程状态初始化
    function statusFormat(value,row,index){
        return row.suspended?"已挂起" : "正常" + " V : " + row.actVersion;
    }

    //流程状态初始化
    function versionFormat(value,row,index){
        return " V : " + row.actVersion;
    }

    //借阅形式初始化
    function borTypeFormat(value,row,index){
        if(value==0){
            return "线上";
        }else{
            return "线下";
        }
    }

    //初始化文件\类
    function fileTypeFormat(value,row,index){
        return fileTypeJson[value];
    }

    //流程状态初始化
    function taskNameFormat(value,row,index){
        return '<a style="color: blue" href="#" pid="'+row.processId+'" pdid="'+row.processDefinitionId+'" onclick="watchProcessPic(this);" title="点击查看流程图">'+value+'</a>';
    }

    //初始化流程结束原因
    function borPurposeFormat(value,row,index){
        if(value==null){
            return "正常结束";
        }else{
            return value;
        }
    }

    //初始化当前执行的任务类型
    function taskTypeFormat(value,row,index){
        if(value==0){
            return "借阅";
        }else if(value==1){
            return "续借";
        }
    }

    //初始化档号问题
    function extend1Format(value,row,index){
        if(value==null||value==" "){
            return "无";
        }else{
            return value;
        }
    }

    //审批结果初始化
    function extend2Format(value,row,index){
        if(value==0){
            return '<span class="label label-default">不通过</span>';
        }else{
            return '<span class="label label-success">通过</span>';
        }
    }

    //初始化预计归还时间
    function planReturnFormat(value,row,index){
        //如果为借阅，则显示预计归还时间
        if(row.taskType==0){
            return formatshortDateTime(row.planReturnTime);;
            //否则，为续借，显示续借归还时间
        }else{
            return formatshortDateTime(row.renewReturnTime);;
        }
    }

    //初始化预计归还时间
    function finishPlanReturnFormat(value,row,index){
        var returnDescription = row.returnDescription;
        var returnTimeJson = JSON.parse(returnDescription);
        var processInstanceId = row.processDefinitionId;
        //如果为续借阅，则显示描述中写入的时间
        if(returnTimeJson!=null&&returnTimeJson[processInstanceId]!=null&&typeof(returnTimeJson[processInstanceId])!='undefined'){
            return formatshortDateTime(returnTimeJson[processInstanceId]);
        }else{
            return formatshortDateTime(value);
        }


    }
    /************************************我的历史的流程总览（结束）****************************/

    /************************************审批逻辑（开始）****************************/
    function borAuditResult(type){
        var taskId = $("#taskId").val();
        var borId = $("#borId").val();
        var taskType = $("#taskType").val();
        var auditUserView = $("#auditUserView").val();
        var flag;
        var delegateUser;
        var userName;
        if(type){
            flag = "true";
            //替代实际人
            delegateUser=$("#auditUserTable").attr("data-delegateUser");
            //判断当前是否为指定审批人表达式
            if(delegateUser!=''||typeof(delegateUser)!="undefined"){
                userName=$("#auditUserTable").val();
            }
        }else{
            flag = "flase";
        }
        $.ajax({
            url:"${basePath}/pcwindow/borAuditResult",
            type:"post",
            data:{taskId:taskId,borId:borId,auditUserView:auditUserView,keys:"pass",values:flag,types:'B',taskType:taskType,delegateUser:delegateUser,userName:userName},
            dataType:"json",
            success:function(data){
                if(data.code==1){
                    $("#borAuditInfo").modal("hide");
                    $borAuditTable.bootstrapTable('refresh');
                }
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                confirmEvent('系统开小差了，请稍后再试!');
            }
        })
    }
    /************************************审批逻辑（结束）****************************/

    /**
     * 查看流程图
     */
    function watchProcessPic(evn){
        var processId = $(evn).attr("pid");
        var processDefinitionId = $(evn).attr("pdid");
        graphTrace(processId,processDefinitionId);
    }

</script>

</body>
</html>